package org.zoomdev.zoom.web.handlers;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.zoomdev.zoom.web.ExceptionHandler;
import org.zoomdev.zoom.web.exception.StatusException;
import org.zoomdev.zoom.web.modules.CoreWebModule;
import org.zoomdev.zoom.web.rendering.impl.HtmlRendering;

import java.io.IOException;

public final class DefaultExceptionHandler extends ExceptionHandler {

    private static final Logger log = LoggerFactory.getLogger(CoreWebModule.class);


    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, Throwable e) {
        try {
            HtmlRendering.render(new StatusException.ServerException(), response);
        } catch (IOException ex) {
            log.error("PrintExceptionHandler", ex);
        }
    }
}
